package com.fxsh168.server.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.widget.TextView;

import com.fxsh168.server.R;
import com.fxsh168.server.base.BaseActivity;
import com.fxsh168.server.entitys.ShengMingEntity;
import com.fxsh168.server.interfaces.Constant;
import com.google.gson.Gson;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import okhttp3.Call;

public class ShengMingActivity extends BaseActivity {
    TextView teMain;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sheng_ming);
        teMain = (TextView) findViewById(R.id.teMain);
        getShengMing();
    }

    //    声明
    private void getShengMing() {
        OkHttpUtils.get().url(Constant.SHEMHMING).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                showToast("网络连接失败");
            }

            @Override
            public void onResponse(String response, int id) {
                Log.e("tag", "法律声明获取" + response);
                ShengMingEntity shengMingEntity = new Gson().fromJson(response, ShengMingEntity.class);
                String code = shengMingEntity.getCode();
                if (code.equals("200")) {
                    String driver_agreement = shengMingEntity.getData().get(0).getDriver_agreement();
                    teMain.setText(driver_agreement);
                }
            }
        });
    }
}
